<?php
class Rewardpoints_Model_Validator extends Mage_SalesRule_Model_Validator
{
	
	public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
	{
		parent::process($item);

		try {
                    $customer = Mage::getSingleton('customer/session');
                    if ($customer->isLoggedIn()){
                        Mage::getModel('rewardpoints/discount')->apply($item);
                    }
                    //else return null;

                    //return $this->_discount->apply($observer->getEvent()->getItem());
                } catch (Mage_Core_Exception $e) {
                    Mage::getSingleton('checkout/session')->addError($e->getMessage());
                } catch (Exception $e) {
                   Mage::getSingleton('checkout/session')->addError($e);
                }
		return $this;
	}
}
